﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

namespace Capstone.DTU.DSMS
{
    public class TestUserPass
    {
        public int Kiemtra(string id, string pass)
        {
            SqlConnection Conn = new SqlConnection(@"Data Source=KHOAHN-PC\KHOAHN;Initial Catalog=Demo_DSMS;Integrated Security=True");
            if (Conn.State == ConnectionState.Closed)
            {
                Conn.Open();
            }
            SqlCommand Cmd = new SqlCommand("SELECT * FROM USERS WHERE Username=@id and Password=@pass", Conn);
            Cmd.Parameters.Add(new SqlParameter("@id", SqlDbType.VarChar, 8));
            Cmd.Parameters.Add(new SqlParameter("@pass", SqlDbType.VarChar, 8));
            Cmd.Parameters["@id"].Value = id;
            Cmd.Parameters["@pass"].Value = pass;
            if (Cmd.ExecuteReader().HasRows)
                return 1;
            else
                return 0;
        }
    }
}